package com.ham.mud.quests;

import com.ham.mud.characters.mobs.Mob;
import com.ham.mud.characters.mobs.MobService;
import com.ham.mud.characters.player.Player;
import com.ham.mud.items.Item;
import com.ham.mud.items.ItemService;
import com.ham.mud.rooms.Room;
import com.ham.mud.rooms.RoomService;

import java.util.Random;

/**
 * Created by hlucas on Jul 19, 2011 at 11:26:53 AM
 */
public class QuestService {
    private static final Random rand = new Random();

    public static Quest newQuest(Player player) {
        Quest quest;
        if(rand.nextBoolean()) {
            quest = new FindQuest(getRewardPoints(), getRewardGold());
            Room randomRoom = RoomService.getRandomRoom();
            ((FindQuest)quest).setRoom(randomRoom);
            Item questItem = ItemService.getQuestItem();
            ((FindQuest)quest).setItem(questItem);
            randomRoom.addItem(questItem);
        } else {
            quest = new KillQuest(getRewardPoints(), getRewardGold());
            Mob mob = MobService.getRandomMob();
            ((KillQuest)quest).setMob(mob);
        }

        return quest;
    }

    private static int getRewardGold() {
        return 20 + rand.nextInt(31);
    }

    public static int getRewardPoints() {
        return 20 + rand.nextInt(31);
    }
}
